package graph;

/**
 * Node representing an 'if' statement. This class has a reference to the Node 
 * representing the condition, another the sequence of statements executed if the
 * condition is true (then), the last the sequence that executed if the condition is false (else)
 * 
 * @author Habib
 *
 */

public class IfNode extends Node
{
	/**
	 * The Node representing the condition
	 */
	public BoolValueNode conditionNode;
	
	/**
	 * The Node representing the sequence of statements executed if the
	 * condition is true (then)
	 */
	public BlockNode thenNode;
	
	/**
	 * The Node representing the sequence of statements executed if the
	 * condition is false (else)
	 */
	public BlockNode elseNode;
	
	/**
	 * Create a Node with null references.
	 */
	public IfNode()
	{
		conditionNode = null;
		thenNode = null;
		elseNode = null;
	}
	
	/**
	 * Sets the Node representing the condition.
	 * 
	 * @param node
	 */
	public void setConditionNode(BoolValueNode node)
	{
		conditionNode = node;
	}
	
	/**
	 * Sets the Node representing the sequence of statements executed if the
	 * condition is true (then)
	 */
	public void setThenNode(BlockNode node)
	{
		thenNode = node;
	}
	
	/**
	 * Sets the Node representing the sequence of statements executed if the
	 * condition is false (else)
	 */
	public void setElseNode(BlockNode node)
	{
		elseNode = node;
	}
	
	/**
	 * Returns the condition node.
	 * 
	 * @return
	 */
	public BoolValueNode getConditionNode()
	{
		return conditionNode;
	}
	
	/**
	 * Returns the Then node.
	 * @return
	 */
	public BlockNode getThenNode()
	{
		return thenNode;
	}
	
	/**
	 * Returns the Else node.
	 * @return
	 */
	public BlockNode getElseNode()
	{	
		return elseNode;
	}
	
	public String toString()
	{
		return "if";
	}
}